Skip to content

Add validation + compatibility tests for DeepLabCut-live#56

Open
deruyter92 wants to merge 16 commits intocy/pre-release-fixes-2.0from
jaap/add_compatibility_tests
Open

Add validation + compatibility tests for DeepLabCut-live#56
deruyter92 wants to merge 16 commits intocy/pre-release-fixes-2.0from
jaap/add_compatibility_tests

Conversation

@deruyter92
Copy link

@deruyter92 deruyter92 commented Feb 27, 2026

Motivation:
Since DeepLabCut-live-GUI heavily depends on DeepLabCut-live, but currenly it is implicitly assumed that that package provides the right output. It would be good to add some basic explicit validation of the returned output of DeepLabCut-live to check compatibility of the returned data. Also, including functional compatibility checks in CI for different DeepLabcut-live versions, allows to systematically tets the package compatibility before release.

Changes:

  • Add PosePacket a lightweight schema validation of the output from DeepLabCut-live
  • Add tests for package compatibility for different DeepLabCut-live versions
  • Various CI improvements/robustness fixes

This pull request introduces significant improvements to DLCLive compatibility testing and pose validation in both the codebase and CI infrastructure. The main changes include adding a dedicated compatibility test suite for DLCLive versions, implementing robust pose array validation, and updating the workflow and test environments to support these enhancements.

DLCLive compatibility testing:

  • Added a new test suite tests/compat/test_dlclive_package_compat.py that verifies DLCLive package importability, constructor signatures, required methods, and performs a minimal inference smoke test. This ensures that the GUI remains compatible with supported DLCLive versions.
  • Introduced a stub for torch in tests/compat/conftest.py to allow compatibility tests to run even if torch is not installed, improving test robustness.

Pose validation and contract enforcement:

  • Implemented a new validate_pose_array function in dlclivegui/services/dlc_processor.py to enforce shape, dtype, and value constraints on pose outputs, preventing downstream errors from invalid data.
  • Updated the processor to use the new pose validation and packet structure, ensuring consistent handling and emission of pose results. [1] [2]
  • Added unit tests for pose array validation in tests/services/test_pose_contract.py, covering both valid and invalid cases.

Continuous integration and test environment updates:

  • Added a new dlclive-compat job to .github/workflows/testing-ci.yml to run compatibility tests against multiple DLCLive versions (PyPI and GitHub main), and updated tox configuration to include corresponding environments. [1] [2] [3]
  • Updated test markers in pyproject.toml to include dlclive_compat and excluded these tests from the default coverage run. [1] [2]

GUI camera validation timer improvements:

  • Refactored camera validation in dlclivegui/gui/main_window.py to use a cancellable QTimer attribute and ensure it is stopped in closeEvent, reducing test/CI errors related to GUI teardown timing. [1] [2]

These changes improve reliability, maintainability, and future-proofing of the DLCLive integration and pose processing pipeline.

@deruyter92 deruyter92 changed the title Jaap/add compatibility tests Add compatibility tests for DeepLabCut-live Feb 27, 2026
@deruyter92 deruyter92 changed the title Add compatibility tests for DeepLabCut-live Add validation + compatibility tests for DeepLabCut-live Feb 27, 2026
Copy link

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks !

Copy link

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deruyter92 If you'd like I can merge #55 right now, so then we can see how the tests go in CI ?

@deruyter92
Copy link
Author

Yes great thanks. Sorry I see that I didn't install the pre-commit

@C-Achard
Copy link

Sorry, in the above I meant #55. It is now merged, happy to take care of conflicts/CI if you're busy !

@C-Achard C-Achard mentioned this pull request Feb 27, 2026
20 tasks
@C-Achard C-Achard force-pushed the jaap/add_compatibility_tests branch from 54ee55e to 693c931 Compare February 27, 2026 15:09
Remove the earlier pytest commands block and update the tox 'commands' to run pytest with the marker excluding both 'hardware' and 'dlclive_compat'. Adjust coverage invocation to use the installed package path (--cov={envsitepackagesdir}/dlclivegui) and emit per-env XML coverage files (.coverage.{envname}.xml). This aligns tox behavior with the GitHub Actions job and removes the prior posargs-based command duplication.
Update the GitHub Actions testing matrix to run on Python 3.12 instead of 3.11. This moves CI to test against the newer Python runtime while keeping existing matrix include entries unchanged.
@deruyter92
Copy link
Author

I see that some tests are failing still. I am happy to pick this up later. Importantly this shouldn't hold you back from releasing the bèta-test version. These validation measures can always be added later.

C-Achard added 5 commits March 2, 2026 09:25
Add a PoseBackends Enum and switch PoseSource.backend from a string to that enum for stronger typing and clarity. Update default PosePacket/PoseSource instances and the validate_pose_array signature to use PoseBackends.DLC_LIVE. Import Enum/auto and remove an unused sentinel variable. These are small refactors to improve type-safety and consistency around backend identification.
Relax and correct DLCLive compatibility checks: only consider keyword/positional params when inspecting __init__, drop the assertion that __init__ must accept **kwargs, and only require 'frame' for init_inference/get_pose (frame_time is passed as a kwarg to processors). Also update FakeDLCLive.get_pose to return an array of shape (2, 3) to match the expected pose output shape.
Set the test step shell to `bash -eo pipefail` and redirect `tox` stderr into `tee` (changed `tox -q` to `tox -q 2>&1 | tee tox-output.log`). This ensures pipeline failures are detected (pipefail) and that tox's stderr is recorded in `tox-output.log` for improved debugging in the CI workflow.
Replace ad-hoc DLCLive installs in the GitHub Actions job with tox-based testenvs. The workflow fixes Python to 3.12, installs required Qt/OpenGL runtime libs on Ubuntu, installs tox and tox-gh-actions, and runs tox -e matrix.tox_env. tox.ini was extended with dlclive-pypi and dlclive-github testenvs (pypi pinned and GitHub main respectively) to run the compatibility pytest, and the new envs were added to env_list to allow local and CI execution.
@C-Achard
Copy link

C-Achard commented Mar 2, 2026

@deruyter92 A few additions :

  1. Added a PoseBackend enum to simplify future work with alternate backends
  2. Fixed an older issue/mistake I made in the CI that would result in the CI job passing despite job failure due to piping commands
  3. Routed the compat tests through tox to reduce install steps and keep env consistent.
    Let me know what you think !

Add tests/compat/conftest.py to inject a stub torch module into sys.modules when torch is not installed. This prevents ImportError during DLCLive compatibility tests so the API can be validated without requiring torch to be installed. This is a pragmatic workaround and includes a note to remove or replace it once imports are properly guarded in the package.
@C-Achard
Copy link

C-Achard commented Mar 2, 2026

I also had to monkeypatch torch in the compat tests due to unguarded imports in DLCLive, see DeepLabCut/DeepLabCut-live#168

Replace QTimer.singleShot with a cancellable QTimer instance (self._camera_validation_timer) that is single-shot, connected to _validate_configured_cameras, and started with a 100ms delay. The closeEvent now stops the timer if it's still active to prevent validation from firing while the window is closing, avoiding modal QMessageBox races/crashes during tests/CI teardown.
@C-Achard C-Achard added DLClive Related to DLCLive inference, versioning, model export... CI Related to CI, tests, workflows... labels Mar 2, 2026
@C-Achard C-Achard marked this pull request as ready for review March 2, 2026 09:31
@C-Achard C-Achard self-requested a review March 2, 2026 09:31
Copy link

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving again, will wait for your feedback next week @deruyter92 before merging as this is agreed not to be beta-critical; thanks again for all the valuable additions !

@C-Achard C-Achard mentioned this pull request Mar 2, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Related to CI, tests, workflows... DLClive Related to DLCLive inference, versioning, model export...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants